package com.ny.demo;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        TestList testList = new TestList();
        List<Emp> list = new ArrayList();
        Emp emp = new Emp();
        boolean  flag = true ;

        while (flag){
            System.out.println("欢迎进入员工系统");
            System.out.println("0.退出系统");
            System.out.println("1.添加员工");
            System.out.println("2.查询所有员工信息");
            System.out.println("3.根据姓名查询员工");
            System.out.println("4.删除员工信息");
            System.out.println("5.根据员工编号查询");
            System.out.println("6.根据员工编号修改年龄");
            System.out.println("请选择功能");
            Scanner scanner =new Scanner(System.in);
            int n = scanner.nextInt();
            switch (n){
                case 0:
                    System.out.println("已退出系统");
                    flag = false;
                    break;

                case 1:
                    System.out.println("请输入添加员工的编号");
                    String addNumber = scanner.next();
                    System.out.println("请输入添加员工的姓名");
                    String addName = scanner.next();
                    System.out.println("请输入添加员工的年龄");
                    int addAge = scanner.nextInt();
                    Emp addEmp = new Emp(addNumber,addName,addAge);

                    testList.addEmp(list,addEmp);
                    System.out.println("添加成功"+addEmp);
                    break;

                case 2:
                    System.out.println("查询所有员工信息");
                    testList.findAllEmp(list);
                break;
                case 3:
                    System.out.println("根据员工姓名查询信息");
                    System.out.println("请输入需要查询的员工姓名");
                    String empName = scanner.next();
                    emp = testList.findEmpName(list,empName);
                    System.out.println(emp);
                    break;

                case 4:
                    System.out.println("删除员工");
                    System.out.println("请输入需要删   除的员工的编号");
                    String empNumber = scanner.next();
                    testList.deleteEmp(list,empNumber);
                    System.out.println(list);
                    break;

                case 5:
                    System.out.println("根据员工编号查询信息");
                    System.out.println("请输入需要查询的员工编号");
                    String empNumber2 = scanner.next();
                    emp = testList.findEmpNumber(list,empNumber2);
                    System.out.println(emp);
                    break;

                case 6:
                    System.out.println("根据员工编号修改年龄");
                    System.out.println("请输入你需要修改年龄的编号");
                    String updateNumber = scanner.next();
                    System.out.println("请输入修改后的年龄");
                    int updateAge = scanner.nextInt();
                   emp= testList.findEmpNumber(list,updateNumber);
                   emp.setAge(updateAge);
                   testList.updateEmpAge(list,emp);
                    System.out.println(list);


                }
            }

        }
    }


